﻿<cfsilent>
	<cfscript>

		event.setArg("pageTitle", "学生点名册");

		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");
		
		taskId = event.getArg("TSK");
		taskType = event.getArg("TT");
		
		/* 载入教学任务 */
		switch (taskType) {
			
			case "C":
				
				sql = "SELECT 
							a.term_id, 
							t_course.course_code, 
							a.cidx, 
							t_institute.institute_name, 
							t_course.course_name, 
							tch.tch_name, 
							tch.tch_id tch_id, 
							tch_sec.tch_id sec_id, 
							tch_sec.tch_name sec_name,  
							tch_ace.tch_id ace_id, 
							tch_ace.tch_name ace_name, 
							t_term.academic_year, 
							t_term.academic_term, 
							t_course.course_credit   
						FROM  
							t_common_task a
							INNER JOIN t_course ON t_course.cid = a.cid 
							INNER JOIN t_institute ON t_institute.institute_id = t_course.institute_id 
							INNER JOIN t_teacher tch ON tch.tch_id = a.tch_id 
							INNER JOIN t_teacher tch_ace ON tch_ace.tch_id = a.tch_id_ace 
							INNER JOIN t_teacher tch_sec ON tch_sec.tch_id = a.tch_id_sec 
							INNER JOIN t_term ON t_term.term_id = a.term_id 
						WHERE 
							a.tsk_id = :taskId ";
				break;

			case "P":

				sql = "SELECT 
							a.term_id, 
							t_course.course_code, 
							a.cidx, 
							t_institute.institute_name, 
							t_course.course_name, 
							tch.tch_name, 
							tch.tch_id tch_id, 
							tch_sec.tch_id sec_id, 
							tch_sec.tch_name sec_name,  
							tch_ace.tch_id ace_id, 
							tch_ace.tch_name ace_name, 
							t_term.academic_year, 
							t_term.academic_term, 
							t_course.course_credit   
						FROM  
							t_task a
							INNER JOIN t_course ON t_course.cid = a.cid 
							INNER JOIN t_institute ON t_institute.institute_id = t_course.institute_id 
							INNER JOIN t_teacher tch ON tch.tch_id = a.tch_id 
							INNER JOIN t_teacher tch_ace ON tch_ace.tch_id = a.tch_id_ace 
							INNER JOIN t_teacher tch_sec ON tch_sec.tch_id = a.tch_id_sec 
							INNER JOIN t_term ON t_term.term_id = a.term_id 
						WHERE 
							a.tsk_id = :taskId ";
				break;
			
			case "T":

				sql = "SELECT 
							a.term_id, 
							t_course.course_code, 
							a.cidx, 
							t_institute.institute_name, 
							t_course.course_name, 
							tch.tch_name, 
							tch.tch_id tch_id, 
							tch_sec.tch_id sec_id, 
							tch_sec.tch_name sec_name,  
							tch_ace.tch_id ace_id, 
							tch_ace.tch_name ace_name, 
							t_term.academic_year, 
							t_term.academic_term, 
							t_course.course_credit   
						FROM  
							t_sport_task a
							INNER JOIN t_course ON t_course.cid = a.cid 
							INNER JOIN t_institute ON t_institute.institute_id = t_course.institute_id 
							INNER JOIN t_teacher tch ON tch.tch_id = a.tch_id 
							INNER JOIN t_teacher tch_ace ON tch_ace.tch_id = a.tch_id_ace 
							INNER JOIN t_teacher tch_sec ON tch_sec.tch_id = a.tch_id_sec 
							INNER JOIN t_term ON t_term.term_id = a.term_id 
						WHERE 
							a.tsk_id = :taskId ";
				break;
			
			case "R":

				 sql = "SELECT 
							a.term_id, 
							t_course.course_code, 
							a.cidx, 
							t_institute.institute_name, 
							t_course.course_name, 
							tch.tch_name, 
							tch.tch_id tch_id, 
							tch_sec.tch_id sec_id, 
							tch_sec.tch_name sec_name,  
							tch_ace.tch_id ace_id, 
							tch_ace.tch_name ace_name, 
							t_term.academic_year, 
							t_term.academic_term, 
							t_course.course_credit   
						FROM  
							t_reopen_task a
							INNER JOIN t_course ON t_course.cid = a.cid 
							INNER JOIN t_institute ON t_institute.institute_id = t_course.institute_id 
							INNER JOIN t_teacher tch ON tch.tch_id = a.tch_id 
							INNER JOIN t_teacher tch_ace ON tch_ace.tch_id = a.tch_id_ace 
							INNER JOIN t_teacher tch_sec ON tch_sec.tch_id = a.tch_id_sec 
							INNER JOIN t_term ON t_term.term_id = a.term_id 
						WHERE 
							a.tsk_id = :taskId ";				
				break;
			
		}
		queryObj = new query( datasource=application.dnsSlave );
		queryObj.addParam( name="taskId", value=taskId, cfsqltype="cf_sql_varchar" );
		rs_task = queryObj.execute( sql=sql ).getResult();
		
		/* 学校信息 */
		sql = "SELECT sch_name FROM t_school ";
		queryObj = new query( datasource=application.dnsSlave );
		rs_school = queryObj.execute( sql=sql ).getResult();

		/* 选课数据 */
		sql = "SELECT 
				t_student.stu_id, 
				t_student.stu_name, 
				t_class.cls_name, 
				t_class.grade, 
				t_student_course.st 				
			FROM 
				t_student_course 
				INNER JOIN t_student ON t_student.stu_id = t_student_course.stu_id 
				INNER JOIN t_class ON t_class.cls_id = t_student.cls_id 
			WHERE 
				t_student_course.task_id = :taskId 
			ORDER BY 
				t_student.stu_id ";
		queryObj = new query( datasource=application.dnsSlave );
		queryObj.addParam( name="taskId", value=taskId, cfsqltype="cf_sql_varchar" );
		rs_chooser = queryObj.execute( sql=sql ).getResult();
		
		rowPerPage = 40;
		
		if ( rs_chooser.recordCount mod rowPerPage ) {
			totlePageCount = int(rs_chooser.recordCount/rowPerPage) + 1;
		}
		else {
			totlePageCount = int(rs_chooser.recordCount/rowPerPage);
		}
		
		pageRowBegin = 1;
		pageRowEnd = min(rowPerPage, rs_chooser.recordCount);
		
		tagCode = "DMC-" & rs_task.term_id & "," & rs_task.course_code & "," & rs_task.cidx;

	</cfscript>
</cfsilent>

<cfloop from="1" to="#totlePageCount#" index="currentPage">

	<cfif currentPage GT 1><div class="page_break"></div></cfif>
	<div class="UIprintableTitle"><cfoutput>#rs_school.sch_name#</cfoutput>学生点名册</div>
	<table width="98%" border="0" cellpadding="1" cellspacing="0">
		<tr>
			<td>任课单位 <cfoutput>#rs_task.institute_name#</cfoutput></td>
			<td>教学班 <cfoutput>#rs_task.course_name#</cfoutput>-<cfoutput>#rs_task.tch_name#</cfoutput>-<cfoutput>#rs_task.cidx#</cfoutput></td>
			<td>教师 
				[<cfoutput>#rs_task.tch_id#</cfoutput>]<cfoutput>#rs_task.tch_name#</cfoutput>
				<cfif rs_task.sec_id neq rs_task.tch_id>
				/ [<cfoutput>#rs_task.sec_id#</cfoutput>]<cfoutput>#rs_task.sec_name#</cfoutput>
				</cfif>
				<cfif rs_task.ace_id neq rs_task.tch_id>
				/ [<cfoutput>#rs_task.ace_id#</cfoutput>]<cfoutput>#rs_task.ace_name#</cfoutput>
				</cfif>
			</td>
			<td align="right">选课记录 <cfoutput>#rs_chooser.recordCount#</cfoutput>条</td>
		</tr>
		<tr>
			<td>学期 <cfoutput>#rs_task.academic_year#</cfoutput>-<cfoutput>#rs_task.academic_term#</cfoutput></td>
			<td>课程 <cfif rs_task.course_code neq "">[<cfoutput>#rs_task.course_code#</cfoutput>]</cfif><cfoutput>#rs_task.course_name#</cfoutput></td>
			<td>学分 <cfoutput>#numberFormat(rs_task.course_credit, "_.__")#</cfoutput></td>
			<td align="right">第<cfoutput>#currentPage#</cfoutput>页 共<cfoutput>#totlePageCount#</cfoutput>页</td>
		</tr>
	</table>
	<table class="UIprintable" width="100%" border="1" cellpadding="5" cellspacing="1">
		<thead>
			<tr>
				<td>序</td>
				<td>学号</td>
				<td>姓名</td>
				<td>班级</td>
				<td>年级</td>
				<td>修读方式</td>
				
				<td>一</td>
				<td>二</td>
				<td>三</td>
				<td>四</td>
				<td>五</td>
				<td>期中</td>
				<td>期末</td>
			</tr>
		</thead>
		<tbody>
			<cfloop index="row" from="#pageRowBegin#" to="#pageRowEnd#">
				<tr>
					<td><cfoutput>#row#</cfoutput></td>
					<td><cfoutput>#rs_chooser["stu_id"][row]#</cfoutput></td>
					<td><cfoutput>#rs_chooser["stu_name"][row]#</cfoutput></td>
					<td><cfoutput>#rs_chooser["cls_name"][row]#</cfoutput></td>
					<td><cfoutput>#rs_chooser["grade"][row]#</cfoutput></td>
					<td><cfoutput>#dictAdvice.getStudyType(rs_chooser["st"][row])#</cfoutput></td>
					
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
				</tr>
			</cfloop>
		</tbody>
	</table>
	<div class="clear2px"></div>
	<table width="100%" cellpadding="0" cellspacing="0">
		<tr>
			<td>打印时间 <cfoutput>#dateFormat(now(), "YYYY年MM月DD日")#</cfoutput></td>
			<td align="right"><img src="<cfoutput>#getContextRoot()#</cfoutput>/barcode/Print/<cfoutput>#tagCode#</cfoutput>.png" height="43"/></td>
		</tr>
	</table>
	
	<cfset pageRowBegin = pageRowBegin + rowPerPage />
	<cfset pageRowEnd = pageRowEnd + rowPerPage />
	<cfif pageRowEnd gt rs_chooser.recordCount>
		<cfset pageRowEnd = rs_chooser.recordCount />
	</cfif>
	
</cfloop>
